From e8f6ed261e213ced6c0c762988b6fc3446ef510a Mon Sep 17 00:00:00 2001
From: Derek Lesho <dlesho@codeweavers.com>
Date: Wed, 22 Apr 2020 10:45:46 -0500
Subject: [PATCH 1/8] mk11_base

---
 configure                  |  2 ++
 configure.ac               |  1 +
 dlls/gfesdk/Makefile.in    |  7 ++++
 dlls/gfesdk/gfesdk.spec    | 16 +++++++++
 dlls/gfesdk/gfesdk_main.c  | 70 ++++++++++++++++++++++++++++++++++++++
 dlls/gfesdk/nvgsdk.h       | 30 ++++++++++++++++
 dlls/ntdll/signal_x86_64.c | 11 +++++-
 dlls/wbemprox/builtin.c    |  8 +++--
 dlls/ws2_32/Makefile.in    |  1 +
 9 files changed, 148 insertions(+), 22 deletions(-)
 create mode 100644 dlls/gfesdk/Makefile.in
 create mode 100644 dlls/gfesdk/gfesdk.spec
 create mode 100644 dlls/gfesdk/gfesdk_main.c
 create mode 100644 dlls/gfesdk/nvgsdk.h

diff --git a/configure b/configure
index 6c4a5f21b5d..0483ccfeda8 100755
--- a/configure
+++ b/configure
@@ -1343,6 +1342,7 @@ enable_fwpuclnt
 enable_gameux
 enable_gdi32
 enable_gdiplus
+enable_gfesdk
 enable_glu32
 enable_gphoto2_ds
 enable_gpkcsp
@@ -20623,6 +20612,7 @@ wine_fn_config_makefile dlls/gdi32 enable_gdi32
 wine_fn_config_makefile dlls/gdi32/tests enable_tests
 wine_fn_config_makefile dlls/gdiplus enable_gdiplus
 wine_fn_config_makefile dlls/gdiplus/tests enable_tests
+wine_fn_config_makefile dlls/gfesdk enable_gfesdk
 wine_fn_config_makefile dlls/glu32 enable_glu32
 wine_fn_config_makefile dlls/gphoto2.ds enable_gphoto2_ds
 wine_fn_config_makefile dlls/gpkcsp enable_gpkcsp
diff --git a/configure.ac b/configure.ac
index 37e3445a342..7700e998067 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3313,6 +3313,7 @@ WINE_CONFIG_MAKEFILE(dlls/gdi32)
 WINE_CONFIG_MAKEFILE(dlls/gdi32/tests)
 WINE_CONFIG_MAKEFILE(dlls/gdiplus)
 WINE_CONFIG_MAKEFILE(dlls/gdiplus/tests)
+WINE_CONFIG_MAKEFILE(dlls/gfesdk)
 WINE_CONFIG_MAKEFILE(dlls/glu32)
 WINE_CONFIG_MAKEFILE(dlls/gphoto2.ds)
 WINE_CONFIG_MAKEFILE(dlls/gpkcsp)
diff --git a/dlls/gfesdk/Makefile.in b/dlls/gfesdk/Makefile.in
new file mode 100644
index 00000000000..339ccfd7e71
--- /dev/null
+++ b/dlls/gfesdk/Makefile.in
@@ -0,0 +1,7 @@
+MODULE = gfesdk.dll
+IMPORTLIB = gfesdk
+
+EXTRADLLFLAGS = -mno-cygwin
+
+C_SRCS = \
+    gfesdk_main.c
diff --git a/dlls/gfesdk/gfesdk.spec b/dlls/gfesdk/gfesdk.spec
new file mode 100644
index 00000000000..816f5bc8aa3
--- /dev/null
+++ b/dlls/gfesdk/gfesdk.spec
@@ -0,0 +1,16 @@
+@ cdecl NVGSDK_AttachLogListener(ptr)
+@ cdecl NVGSDK_Create(ptr ptr ptr)
+@ cdecl NVGSDK_GetUILanguageAsync(ptr ptr ptr)
+#@ cdecl NVGSDK_Highlights_CloseGroupAsync(ptr ptr ptr ptr)
+#@ cdecl NVGSDK_Highlights_ConfigureAsync(ptr ptr ptr ptr)
+#@ cdecl NVGSDK_Highlights_GetNumberOfHighlightsAsync(ptr ptr ptr ptr)
+#@ cdecl NVGSDK_Highlights_GetUserSettingsAsync(ptr ptr ptr)
+#@ cdecl NVGSDK_Highlights_OpenGroupAsync(ptr ptr ptr ptr)
+#@ cdecl NVGSDK_Highlights_OpenSummaryAsync(ptr ptr ptr ptr)
+#@ cdecl NVGSDK_Highlights_SetScreenshotHighlightAsync(ptr ptr ptr ptr)
+#@ cdecl NVGSDK_Highlights_SetVideoHighlightAsync(ptr ptr ptr ptr)
+@ cdecl NVGSDK_Poll(ptr)
+@ cdecl NVGSDK_Release(ptr)
+@ cdecl NVGSDK_RequestPermissionsAsync(ptr ptr ptr ptr)
+@ cdecl NVGSDK_SetListenerLogLevel(long)
+@ cdecl NVGSDK_SetLogLevel(long)
diff --git a/dlls/gfesdk/gfesdk_main.c b/dlls/gfesdk/gfesdk_main.c
new file mode 100644
index 00000000000..f0af7e7568d
--- /dev/null
+++ b/dlls/gfesdk/gfesdk_main.c
@@ -0,0 +1,70 @@
+#include <windef.h>
+
+#include "wine/debug.h"
+
+#include "nvgsdk.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(gfesdk);
+
+NVGSDK_RetCode CDECL NVGSDK_Create(NVGSDK_HANDLE **handle, NVGSDK_CreateInputParams const *params, NVGSDK_CreateResponse *response)
+{
+    FIXME("stub(%p %p %p %p)\n", handle, params, response);
+
+    /* SDK specifies "On fatal error, this will be NULL", which I assume means we clean it? */
+    if (response)
+    {
+        //memset(response, 0, sizeof(*response));
+    }
+
+    return NVGSDK_ERR_LOAD_LIBRARY;
+}
+
+NVGSDK_RetCode CDECL NVGSDK_Release(NVGSDK_HANDLE *handle)
+{
+    FIXME("stub(%p)\n", handle);
+
+    return NVGSDK_ERR_INVALID_PARAMETER;
+}
+
+NVGSDK_RetCode CDECL NVGSDK_Poll(NVGSDK_HANDLE *handle)
+{
+    FIXME("stub(%p)\n", handle);
+
+    /* SDK doesn't document failure of this function */
+    return NVGSDK_ERR_INVALID_PARAMETER;
+}
+
+NVGSDK_RetCode CDECL NVGSDK_SetLogLevel(NVGSDK_LogLevel lvl)
+{
+    FIXME("stub(%u)\n", lvl);
+
+    return NVGSDK_SUCCESS;
+}
+
+NVGSDK_RetCode CDECL NVGSDK_AttachLogListener(NVGSDK_LoggingCallback callback)
+{
+    FIXME("stub(%p)\n");
+
+    return NVGSDK_SUCCESS;
+}
+
+NVGSDK_RetCode CDECL NVGSDK_SetListenerLogLevel(NVGSDK_LogLevel lvl)
+{
+    FIXME("stub(%u)\n");
+
+    return NVGSDK_SUCCESS;
+}
+
+void CDECL NVGSDK_RequestPermissionsAsync(NVGSDK_HANDLE *handle, NVGSDK_RequestPermissionsParams const *params, NVGSDK_EmptyCallback callback, void *context)
+{
+    FIXME("stub(%p %p %p %p)\n", handle, params, callback, context);
+
+    callback(NVGSDK_SUCCESS, context);
+}
+
+void CDECL NVGSDK_GetUILanguageAsync(NVGSDK_HANDLE *handle, NVGSDK_GetUILanguageCallback callback, void *context)
+{
+    FIXME("stub(%p %p %p)\n", handle, callback, context);
+
+    callback(NVGSDK_ERR_NOT_SET, NULL, context);
+}
diff --git a/dlls/gfesdk/nvgsdk.h b/dlls/gfesdk/nvgsdk.h
new file mode 100644
index 00000000000..457f2340738
--- /dev/null
+++ b/dlls/gfesdk/nvgsdk.h
@@ -0,0 +1,30 @@
+#include <windef.h>
+
+typedef struct _NVGSDK_HANDLE NVGSDK_HANDLE;
+
+typedef struct _NVGSDK_CreateInputParams NVGSDK_CreateInputParams;
+
+typedef struct _NVGSDK_CreateResponse NVGSDK_CreateResponse;
+
+typedef struct _NVGSDK_RequestPermissionsParams NVGSDK_RequestPermissionsParams;
+
+typedef struct _NVGSDK_Language NVGSDK_Language;
+
+typedef enum _NVGSDK_LogLevel
+{
+  NVGSDK_LOG_NONE = 0,
+} NVGSDK_LogLevel;
+
+typedef enum _NVGSDK_RetCode
+{
+    NVGSDK_SUCCESS = 0,
+    NVGSDK_ERR_INVALID_PARAMETER = -1005,
+    NVGSDK_ERR_NOT_SET = -1006,
+    NVGSDK_ERR_LOAD_LIBRARY = -1022,
+} NVGSDK_RetCode;
+
+typedef void (CALLBACK *NVGSDK_LoggingCallback)(NVGSDK_LogLevel lvl, char const *msg);
+
+typedef void(CALLBACK *NVGSDK_EmptyCallback)(NVGSDK_RetCode ret, void *context);
+
+typedef void(CALLBACK *NVGSDK_GetUILanguageCallback)(NVGSDK_RetCode ret, NVGSDK_Language const *lang, void *context);
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index 89caca9f30f..6fb16333397 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -2431,12 +2431,21 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
     UNWIND_HISTORY_TABLE table;
     DISPATCHER_CONTEXT dispatch;
     CONTEXT context;
+    MEMORY_BASIC_INFORMATION wine_frame_stack_info, current_stack_info;
+    int is_teb_frame_in_current_stack = 1;
     NTSTATUS status;
 
     context = *orig_context;
     dispatch.TargetIp      = 0;
     dispatch.ContextRecord = &context;
     dispatch.HistoryTable  = &table;
+
+    if ( !(NtQueryVirtualMemory(NtCurrentProcess(), teb_frame, MemoryBasicInformation, &wine_frame_stack_info, sizeof(MEMORY_BASIC_INFORMATION), NULL)) &&
+         !(NtQueryVirtualMemory(NtCurrentProcess(), (PVOID)context.Rsp, MemoryBasicInformation, &current_stack_info, sizeof(MEMORY_BASIC_INFORMATION), NULL)))
+    {
+        is_teb_frame_in_current_stack = wine_frame_stack_info.AllocationBase == current_stack_info.AllocationBase;
+    }
+
     for (;;)
     {
         status = virtual_unwind( UNW_FLAG_EHANDLER, &dispatch, &context );
@@ -2482,7 +2491,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
             }
         }
         /* hack: call wine handlers registered in the tib list */
-        else while ((ULONG64)teb_frame < context.Rsp)
+        else if (is_teb_frame_in_current_stack) while ((ULONG64)teb_frame < context.Rsp)
         {
             TRACE( "found wine frame %p rsp %lx handler %p\n",
                     teb_frame, context.Rsp, teb_frame->Handler );
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index 24badb7bf92..e5d8b2400aa 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -374,6 +374,7 @@ static const struct column col_sounddevice[] =
     { L"Name",        CIM_STRING },
     { L"ProductName", CIM_STRING },
     { L"StatusInfo",  CIM_UINT16 },
+    { L"Manufacturer", CIM_STRING },
 };
 static const struct column col_stdregprov[] =
 {
@@ -759,6 +760,7 @@ struct record_sounddevice
     const WCHAR *name;
     const WCHAR *productname;
     UINT16       statusinfo;
+    const WCHAR *manufacturer;
 };
 struct record_stdregprov
 {
@@ -876,7 +878,7 @@ static const struct record_quickfixengineering data_quickfixengineering[] =
 };
 static const struct record_sounddevice data_sounddevice[] =
 {
-    { L"Wine Audio Device", L"Wine Audio Device", 3 /* enabled */ }
+    { L"Wine Audio Device", L"Wine Audio Device", 3 /* enabled */, L"The Wine Project" }
 };
 static const struct record_stdregprov data_stdregprov[] =
 {
@@ -2868,11 +2870,11 @@ static enum fill_status fill_physicalmemory( struct table *table, const struct e
 
     rec = (struct record_physicalmemory *)table->data;
     rec->capacity             = get_total_physical_memory();
-    rec->configuredclockspeed = 0;
+    rec->configuredclockspeed = 1600;
     rec->devicelocator        = L"DIMM 0";
     rec->formfactor           = 8; /* DIMM */
     rec->memorytype           = 9; /* RAM */
-    rec->partnumber           = NULL;
+    rec->partnumber           = L"BLS8G3D1609DS1S00";
     if (!match_row( table, row, cond, &status )) free_row_values( table, row );
     else row++;
 
diff --git a/dlls/ws2_32/Makefile.in b/dlls/ws2_32/Makefile.in
index 9d7dfafeb3c..c7f24168dac 100644
--- a/dlls/ws2_32/Makefile.in
+++ b/dlls/ws2_32/Makefile.in
@@ -1,6 +1,7 @@
 EXTRADEFS = -DUSE_WS_PREFIX
 MODULE    = ws2_32.dll
 IMPORTLIB = ws2_32
+IMPORTS = kernelbase
 DELAYIMPORTS = iphlpapi user32
 EXTRALIBS = $(POLL_LIBS)
 
